<template>
	<view>
		<view class="actionList">
			<view class="formGroup">
			<view class="formItem">
				<view class="formLabel">原密码</view>
				<input type="password" placeholder="请输入原密码" class="wq-ipt1" v-model="password1"></input>
			</view>
			<view class="formItem">
				<view class="formLabel">新密码</view>
				<input type="password" placeholder="请输入新密码" class="wq-ipt1" v-model="password2"></input>
			</view>
			<view class="formItem">
				<view class="formLabel">再次输入</view>
				<input type="password" placeholder="请输入新密码" class="wq-ipt1" v-model="password3"></input>
			</view>
			<view class="formItem">
			<button class="wq-btn" @tap="save">保存</button>
			</view>
			</view>
		</view>
	</view>
</template>

<script>
	import api from '@/api.js'
	export default {
		data() {
			return {
				password1:'',
				password2:'',
				password3:'',
			}
		},
		onLoad(e){
			
		},
		methods: {
			save(){
				if(this.password1=='' || this.password2 == '' || this.password3== ''){
					uni.showToast({
						title:"请验证是否填写完整",
						icon:"none"
					})
				}else{
					if(this.password2!=this.password3){
						uni.showToast({
							title:"两次新密码输入不一致，请重新输入",
							icon:"none"
						})
					}else{
						api.doRequest("post",'my/changePwd',{oPwd:this.password1,nPwd:this.password2}).then(res=>{

							
							console.log(res.data.code);
							if(res.statusCode==200 && res.data.code==200){
								uni.showToast({
									title:"修改成功",
									icon:"none"
								})
								setTimeout(function(){
									uni.reLaunch({
										url:'/pages/my/my'
									})
								},500);
								
							}else{
								uni.showToast({
									title:res.data.msg,
									icon:"none"
								})
							}
						})
					}
				}
				
			}
		}
	}
</script>

<style>
.formGroup {
		width: 670upx;
		padding: 20upx;
		margin: 0upx auto;
		margin-bottom: 20upx;
		background: #fff;
		border-radius: 20upx;
	}
	.formLabel {
		font-size: 12px;
		margin: 20upx 0;
	}
	.formItem{
		margin-bottom:20upx;
	}
	.wq-ipt1{
		width:calc(100% - 20upx);border:1upx solid #ccc;height:80upx;border-radius:10upx;padding-left:20upx;
	}
</style>
